﻿using UnityEditor;
using UnityEngine;

public static class MaterialCommands
{
    [MenuItem("CONTEXT/Material/Skinn: Log Properties", false, 1)]
    private static void MaterialLogProperties(MenuCommand command)
    {
        var context = (Material)command.context;
        var shader = context.shader;
        if (!shader) return;
        var info = shader.name + System.Environment.NewLine;
        var propertyCount = ShaderUtil.GetPropertyCount(shader);
        for (int i = 0; i < propertyCount; i++)
        {
            var propName = ShaderUtil.GetPropertyName(shader, i);
            var proptype = ShaderUtil.GetPropertyType(shader, i);
            var propDesc = ShaderUtil.GetPropertyDescription(shader, i);
            info += string.Format(" {0}, {1}, {2}", propName, proptype, propDesc);
            info += System.Environment.NewLine;
        }
        Debug.Log(info);
    }
}
